package be.ipl.eBar.daoimpl;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import be.ipl.eBar.dao.BiereDao;
import be.ipl.eBar.domaine.Biere;

@Stateless
public class BiereDaoImpl extends DaoImpl<Biere> implements BiereDao{

	@Override
	public Biere rechercher(String nom){
		String query = "select b from Biere b where b.nom = ?1";
		return recherche(query,nom);
	}

	@Override
	public List<Biere> lister(String mot){
		mot = mot.toLowerCase();
		String query = "select b from Biere b"+
		"where lower(b.nom) like ?1"+
		"or lower(b.type) like ?1 " + 
		"or lower(b.couleur) like ?1 " + 
		"or lower(b.brasserie.nom) like ?1 "; 
		return liste(query, mot);
	}

//	@Override
//	public Biere chargerFournisseurs(Biere biere){
//		biere = super.recharger(biere.getId());
//		biere.getFournisseurs().size();
//		return biere;
//	}

}
